package redarrow.wb.util;



import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.InvalidPropertiesFormatException;
import java.util.Properties;

public class DBConfig {

	/**
	 * @param args
	 */
	public static boolean databaseEnabled = true;
	
	public static String db_url = "";

	public static String db_account = "";

	public static String db_password = "";
	
	public static int min_limit = 2;

	public static int max_limit = 50;

	public static int initial_limit = 2;

	public static int ConnectionWaitTimeout = 5;

	public static boolean ValidateConnection = true;
	
	
	public static Properties props = new Properties();
	public DBConfig() {
		try {
			loadProperties();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void loadProperties() throws IOException {
		// TODO Auto-generated method stub

		Properties props = new Properties();
        FileInputStream fis = new FileInputStream("c:/properties.xml");
      
        //loading properites from properties file
        props.loadFromXML(fis);    
		db_url = props.getProperty("db_url");
		db_account = props.getProperty("db_account");
		db_password = props.getProperty("db_password");			
	}

	public static void main(String[] args) throws InvalidPropertiesFormatException, IOException {
		// TODO Auto-generated method stub
//		Properties props = new Properties();
//		String message="";
//		//try retrieve data from file
//        try {
//        DBConfig newsonph=new DBConfig();
//        newsonph.loadProperties();
//        System.out.println(newsonph.db_url);
//         }
//        catch (Exception e){
//        	e.printStackTrace();
//        }
		
		//Reading properties file in Java example
        Properties props = new Properties();
        FileInputStream fis = new FileInputStream("c:/properties.xml");
      
        //loading properites from properties file
        props.loadFromXML(fis);

        //reading proeprty
        String username = props.getProperty("db_url");
        System.out.println("db_url: " + username);


		
		
	}

}
